package io.openkunlun.javadsl.server;

public final class FailureDetected {

    public static final FailureDetected AVAILABLE = new FailureDetected(null);
    public static final FailureDetected UNAVAILABLE = new FailureDetected(new IllegalStateException("service unavailable."));

    private final Throwable cause;

    /**
     * @param cause
     */
    public FailureDetected(Throwable cause) {
        this.cause = cause;
    }

    /**
     * @return
     */
    public Throwable cause() {
        return cause;
    }

    /**
     * @return
     */
    public boolean isAvailable() {
        return null == cause;
    }

    /**
     * @return
     */
    public boolean isUnavailable() {
        return null != cause;
    }
}
